package com.biodiv.datamapper.factory;


import com.biodiv.miracle.ioc.factory.FactoryBean;

import java.lang.reflect.Proxy;

/**
 * @author: tianquan
 * @date: 2025-05-30  10:05
 * @description: 生成代理类的类
 */
public class MapperFactoryBean<T> implements FactoryBean<T> {

    private final Class<T> mapperInterface;

    public MapperFactoryBean(Class<T> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    @Override
    public T getObject() {
        return (T) Proxy.newProxyInstance(
                mapperInterface.getClassLoader(),
                new Class[]{mapperInterface},
                new MapperProxy());
    }

    @Override
    public Class<?> getObjectType() {
        return mapperInterface;
    }

}
